//
//  String+Extension.swift
//  Backhome
//
//  Created by vbn on 2018/7/27.
//  Copyright © 2018年 SmartHome. All rights reserved.
//

import Foundation

extension String {
    public func KNWidthOfString(usingFont font: UIFont) -> CGFloat {
        let fontAttributes = [NSAttributedString.Key.font: font]
        let size = self.size(withAttributes: fontAttributes)
        return size.width
    }
    
    public func KNHeightOfString(usingFont font: UIFont) -> CGFloat {
        let fontAttributes = [NSAttributedString.Key.font: font]
        let size = self.size(withAttributes: fontAttributes)
        return size.height
    }
    
    public func KNSizeOfString(usingFont font: UIFont) -> CGSize {
        let fontAttributes = [NSAttributedString.Key.font: font]
        return self.size(withAttributes: fontAttributes)
    }
    
    public func KNTrim() -> String {
        return self.trimmingCharacters(in: NSCharacterSet.whitespaces)
    }
}
